package com.example.team.controller;

import com.example.team.entity.ItemDistribution;
import com.example.team.service.IItemDistributionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 编写者：蓝江富
 * 时间：2023年10月31日19:02:50
 */
@RestController
@Api(tags = "物品发放记录")
public class ItemDistributionController {
    @Autowired
    private IItemDistributionService itemDistributionService;

    @ApiOperation(value = "添加物品发放记录",
            notes = "成功返回1")
    @RequestMapping("/insertItemDistribution")
    public int insertItemDistribution(ItemDistribution itemDistribution){
        return itemDistributionService.insertItemDistribution(itemDistribution);
    }

    @ApiOperation(value = "删除物品发放记录",
            notes = "成功返回1")
    @RequestMapping("/deleteItemDistribution")
    public int deleteItemDistribution(Integer id){
        ItemDistribution itemDistribution=new ItemDistribution();
        itemDistribution.setDistributionId(id);
        return itemDistributionService.deleteItemDistribution(itemDistribution);
    }

    @ApiOperation(value = "修改物品发放记录信息",
            notes = "成功返回1")
    @RequestMapping("/updateItemDistribution")
    public int updateItemDistribution(ItemDistribution itemDistribution){
        return itemDistributionService.updateItemDistribution(itemDistribution);
    }

    @ApiOperation(value = "查询所有物品发放记录信息",
            notes = "成功返回Json")
    @RequestMapping("/getAllItemDistribution")
    public List<ItemDistribution> getAllItemDistribution(Integer issuer){
        ItemDistribution itemDistribution=new ItemDistribution();
        itemDistribution.setIssuer(issuer);
        return itemDistributionService.getAllItemDistribution(itemDistribution);
    }

    @ApiOperation(value = "查询物品发放记录信息",
            notes = "成功返回Json")
    @RequestMapping("/getItemDistribution")
    public ItemDistribution getItemDistribution(Integer issuer){
        ItemDistribution itemDistribution=new ItemDistribution();
        itemDistribution.setIssuer(issuer);
        return itemDistributionService.getItemDistribution(itemDistribution);
    }
}
